<?
$title = "My Order";
require("required/dbconnect.php");
require("required/share_function.php");
$_SESSION['pid'] = -1;
require("required/header.php");
require("required/chkuser.php");
require("required/function.php");

$get_bill = mysql_query("select * from os_bill_details where uid=$member_id and (status>0 or status=-3 or status=-4) and status<6 and is_redeem=0 order by create_date desc") or die(mysql_error());
$count = mysql_num_rows($get_bill);
?>

<table width="100%" cellpadding="6" cellspacing="0">
    <tr>
        <td class='page_title_bar'>
            My Order
        </td>					
    </tr>	

    <tr>
        <Td height="400" valign="top">
            &nbsp;<font class="page_description">This is where you are able to view the status of your pending order(s) </font>
            <table width="100%">
                <?
                if ($count == 0) {
                    ?>
                    <tr>
                        <td align="center"> 
                            :: NO RECORD :: <br>
                            <a href="os_products.php">Start shopping now!</a>
                        </td>
                    </tr>
                    <?
                } else {
                    ?>
                    <form action="<?= $_SERVER['PHP_SELF'] ?>" method="post" name="frm">
                        <tr>
                            <td>
                                <font class="page_description">Below are your current order(s). For more information on the order(s), kindly click on the order that you wish to view. 
                                <br>Please take note that if payment(s) are required, kindly have them made within a week after the order(s) have been verified or they will be automatically removed from the system.
                                </font>
                                <table width="90%" bgcolor="#CCCCCC" cellpadding="1" cellspacing="1">
                                    <tr class="table_header"align="center">
                                        <td width="7%">Order number</td><td width="30%">Order date</td><td width="18%">Total Amount(RM)</td><td width="22%">Receiver</td><td width="23%">Status</td>
                                    </tr>
                                    <?
                                    $no = 1;
                                    while ($c = mysql_fetch_array($get_bill)) {
                                        if (dayDiff($c['create_date']) > 7 and $c['status'] <= 2) {
                                            $update_expired = mysql_query("update os_bill_details set status='-1' where id=" . $c['id']);
                                        } else {

                                            if ($no % 2 == 0) {
                                                $class1 = "table_item_even";
                                                $class2 = "table_item_odd";
                                            } else {
                                                $class1 = "table_item_odd";
                                                $class2 = "table_item_even";
                                            }

                                            $total_amount = $c['total_amount'] + $c['transport_fees'];
                                            ?>
                                            <tr height="30" valign="top" class="<?= $class1 ?>"  onmouseover="this.className='table_item_mouseover'" onmouseout="this.className='<?= $class1 ?>'" align="center">

                                                <td><a href="os_orderstatus.php?id=<?= $c['id'] ?>"><?= $c['order_request_number'] ?></a></td><td><?= $c['create_date'] ?></td>
                                                <td><font color="#FF0000"><?= number_format($total_amount, 2) ?></font></td><td><?= $c['receiver_name'] ?></td>
                                                <td><?= billstatus_eng($c['status']) ?></td>
                                            </tr>
                                            <?
                                        }
                                    }
                                    ?>
                                </table>
                            </td>
                        </tr>

                    </form>
                    <?
                }
                ?>
            </table>

        </Td>
    </tr>		  
</table>

<? require("required/footer.php"); ?>	